﻿using CommunityToolkit.Mvvm.Input;
using NavigateDemo.Services;

namespace NavigateDemo.ViewModels
{
    public partial class LoginViewModel : ViewModelBase
    {
        private readonly NavigationService navigationService;

        [ObservableProperty]
        string? userName = "Sean";

        public LoginViewModel(NavigationService navigationService)
        {
            this.navigationService = navigationService;
        }

        [RelayCommand]
        void Login()
        {
            // 使用新的参数传递导航方法
            navigationService.NavigateTo<HomeViewModel>(vm => vm.UserName = UserName);
        }
    }
}
